def info_print():
    print('请选择功能---------')
    print('1、添加学员')
    print('2、删除学员')
    print('3、修改学员')
    print('4、查询学员')
    print('5、显示所有的学员')
    print('6、退出系统')
    print("-"*20)

info = []

def add_info():
    '''添加学员方法'''
    new_id = input("请输入学号：")
    new_name = input("请输入姓名：")
    new_phone = input("请输入手机号：")

    global info

    for i in info:
        if i['name'] == new_name:
            print("此用户已存在")
            return

    info_dict = {}

    info_dict['id'] = new_id
    info_dict['name'] = new_name
    info_dict['phone'] = new_phone

    print(info_dict)

    info.append(info_dict)

    print(info)

def del_info():
    '''删除学员'''
    del_name = input("请输入要删除学员的姓名：")

    global info

    for i in info:
        if del_name == i["name"]:
            info.remove(i)
            break
    else:
        print("该学员不存在")

    print(info)


def modify_info():
    '''修改信息'''
    modify_name = input("请输入要修改的学员姓名：")

    global info

    for i in info:
        if modify_name == i["name"]:
            i["phone"] = input("请输入新的的手机号：")
            break
    else:
        print("该学员信息不存在")

    print(info)

def search_info():
    '''查找学员'''
    search_name = input("请输入要查找的学员姓名")

    global info

    for i in info:
        if search_name == i["name"]:
            print("该学员的信息如下：")
            print(f"该学员学号{i['id']}, 姓名是{i['name']}, 手机号{i['phone']}")
            break
    else:
        print("不存在该学员")

def search_all_info():
    for i in info:
        print("所有学员的信息如下：")
        print(f"该学员学号{i['id']}, 姓名是{i['name']}, 手机号{i['phone']}")


while True:
    info_print()
    user_num = int(input("请输入功能序号："))
    if user_num == 1:
        add_info()
    elif user_num == 2:
        del_info()
    elif user_num == 3:
        modify_info()
    elif user_num == 4:
        search_info()
    elif user_num == 5:
        search_all_info()
    elif user_num == 6:
        exit_flag = input("确定是要退出吗？yes or no")
        if exit_flag == 'yes':
            break
    else:
        print("输入的信息有误")